package com.example.rocketmq;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @Author: yll
 * @Description: 生产者
 * @Date: 2020/9/16 12:05 上午
 * @Version: 1.0
 */
@Component
public class Producer {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    @Autowired
    private DefaultMQProducer defaultMQProducer;

    @Value("${rocketmq.topc}")
    private String topic;

    public void sendMsg(String msg) {
        rocketMQTemplate.convertAndSend(topic, msg);
    }
}
